/* 
  Copyright (c) SilverLining 2015
  Date:    2016-1-7
  File:    DebugProvider.cpp  
  Description: 

*/

#include "stdafx.h"
#include "DebugProvider.h"
#include "..\m\m_provider.h"

using namespace System;
using namespace System::Security;
using namespace System::Text;
using namespace System::Runtime::InteropServices;

using namespace m::error;

namespace SL
{
	namespace M
	{
		namespace Debug
		{
			int DebugProvider::LastHr::get()
			{
				return m::error::LastHr;
			}

			void DebugProvider::LastHr::set(int error)
			{
				m::error::LastHr = error;
			}

			void DebugProvider::Log(int hr, System::String ^ Fmt, ...array<System::Object^>^ params)
			{
				System::String^ str = nullptr;
				if (params->Length > 0)
				{
					str = String::Format(Fmt, params);
				}
				else
				{
					str = Fmt;
				}
				str = str->Replace("%", "%%");
				pin_ptr<const wchar_t> ptr = PtrToStringChars(str);
				dbg.log(hr, ptr);
			}
		}

	}
}